module TclBot
  module Commands
    class << self
      def require_all_commands
        command_files.each do |command_file|
          require(command_file)
        end
      end
      
      def command_modules
        constants.grep(/Commands?$/).map do |module_name|
          const_get(module_name)
        end
      end
      
      def command_files
        Dir[File.join(File.dirname(__FILE__), *%w"commands *.rb")].map do |filename|
          File.join(File.dirname(filename), File.basename(filename, ".rb"))
        end
      end
    end
    
    require_all_commands
  end
end

